'use strict';
module.exports = {
	/**
	 * XXXnameXXX
	 * @url admin/dls/kh/dytflj/get_tfdata 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let {
			data = {}, userInfo, util, filterResponse, originalParam
		} = event;
		let {
			customUtil,
			uniID,
			config,
			pubFun,
			vk,
			db,
			_
		} = util;
		let {
			uid
		} = data;
		let res = {
			code: 0,
			msg: ""
		};
		// 业务逻辑开始-----------------------------------------------------------

		let get_tflj = await vk.baseDao.select({
			dbName: "a_dy_tfurl",
			whereJson: {
				agentId: uid,
			}
		});

		console.log("get_tflj", get_tflj);

		var time = vk.pubfn.getCommonTime(new Date());
		let todayStart = time.todayStart;
		let batchRun_tflj = await vk.pubfn.batchRun({
			main: async (item, index) => {
				await vk.callFunction({
					name: "hedian",
					url: 'admin/auto_run/pub/batchRun_tflj',
					data: {
						tfid: item._id,
						todayStart,
					}
				});
				return {
					code: 0,
					index
				}
			},
			concurrency: 5,
			data: get_tflj.rows
		});



		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}